import java.util.HashMap;
import java.util.Map;

public class Solution1 {
    public int[] twoSum(int[] nums, int target) {
        Map<Integer, Integer> hash = new HashMap<>(); // <nums[i], i>
        int[] ret = new int[2];
        for(int i = 0; i < nums.length; i++) {
            int x = target - nums[i];
            if(hash.containsKey(x)) {
                ret[0] = i;
                ret[1] = hash.get(x);
                return ret;
            }
            hash.put(nums[i], i);
        }
        return ret;
    }
}
